package com.houweishi.module.subscribepattern.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.houweishi.common.annotation.Log;
import com.houweishi.common.core.controller.BaseController;
import com.houweishi.common.core.domain.AjaxResult;
import com.houweishi.common.enums.BusinessType;
import com.houweishi.module.subscribepattern.domain.BizSubscribePattern;
import com.houweishi.module.subscribepattern.service.IBizSubscribePatternService;
import com.houweishi.common.utils.poi.ExcelUtil;
import com.houweishi.common.core.page.TableDataInfo;

/**
 * 申请表类型管理Controller
 * 
 * @author houweishi
 * @date 2023-02-27
 */
@RestController
@RequestMapping("/module/subscribepattern")
public class BizSubscribePatternController extends BaseController
{
    @Autowired
    private IBizSubscribePatternService bizSubscribePatternService;

    /**
     * 查询申请表类型管理列表
     */
    @PreAuthorize("@ss.hasPermi('module:subscribepattern:list')")
    @GetMapping("/list")
    public TableDataInfo list(BizSubscribePattern bizSubscribePattern)
    {
        startPage();
        List<BizSubscribePattern> list = bizSubscribePatternService.selectBizSubscribePatternList(bizSubscribePattern);
        return getDataTable(list);
    }

    /**
     * 导出申请表类型管理列表
     */
    @PreAuthorize("@ss.hasPermi('module:subscribepattern:export')")
    @Log(title = "申请表类型管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BizSubscribePattern bizSubscribePattern)
    {
        List<BizSubscribePattern> list = bizSubscribePatternService.selectBizSubscribePatternList(bizSubscribePattern);
        ExcelUtil<BizSubscribePattern> util = new ExcelUtil<BizSubscribePattern>(BizSubscribePattern.class);
        util.exportExcel(response, list, "申请表类型管理数据");
    }

    /**
     * 获取申请表类型管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('module:subscribepattern:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(bizSubscribePatternService.selectBizSubscribePatternById(id));
    }

    /**
     * 新增申请表类型管理
     */
    @PreAuthorize("@ss.hasPermi('module:subscribepattern:add')")
    @Log(title = "申请表类型管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BizSubscribePattern bizSubscribePattern)
    {
        return toAjax(bizSubscribePatternService.insertBizSubscribePattern(bizSubscribePattern));
    }

    /**
     * 修改申请表类型管理
     */
    @PreAuthorize("@ss.hasPermi('module:subscribepattern:edit')")
    @Log(title = "申请表类型管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BizSubscribePattern bizSubscribePattern)
    {
        return toAjax(bizSubscribePatternService.updateBizSubscribePattern(bizSubscribePattern));
    }

    /**
     * 删除申请表类型管理
     */
    @PreAuthorize("@ss.hasPermi('module:subscribepattern:remove')")
    @Log(title = "申请表类型管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(bizSubscribePatternService.deleteBizSubscribePatternByIds(ids));
    }
}
